package cn.sfrog.web.controller.tool;

import cn.sfrog.common.core.controller.BaseController;
import cn.sfrog.common.core.domain.AjaxResult;
import cn.sfrog.common.core.domain.ApiAjaxResult;
import cn.sfrog.common.exception.ApiException;
import cn.sfrog.common.exception.LiveException;
import cn.sfrog.project.biz.admin.tencent.TencentApiResponse;
import cn.sfrog.project.biz.admin.tencent.TencentLiveApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author chenl
 * @Date 2024-05-26 13:32
 * @title TestController
 * @description
 **/
@Api("测试使用")
@RestController
@RequestMapping("/test/viper")
public class TestController extends BaseController {

    @Autowired
    private TencentLiveApiService liveApiService;


    @ApiOperation("创建直播群")
    @GetMapping("/createGroup")
    public ApiAjaxResult createGroup() {
        TencentApiResponse apiResponse = liveApiService.createGroup("123456");
        if (apiResponse.getCode() == 10021) {
            return ApiAjaxResult.success(apiResponse.getData());
        }
        return ApiAjaxResult.error(apiResponse.getCode(),apiResponse.getData());

    }


    @ApiOperation("获取所有群组")
    @GetMapping("/getAllGroup")
    public String getAllGroup() {
        String result = liveApiService.getAllGroupList();
        return result;
    }

    @ApiOperation("用户导入")
    @GetMapping("/accountImport")
    public ApiAjaxResult<String> accountImport() {
        TencentApiResponse apiResponse = liveApiService.accountImport("571","developer1","https://szqingwa-oss.oss-cn-shanghai.aliyuncs.com/szqingwa-oss/a6b118576dce4c83989fe65d704cd799.jpg");
        TencentApiResponse apiResponse2 = liveApiService.accountImport("570","developer2","https://szqingwa-oss.oss-cn-shanghai.aliyuncs.com/szqingwa-oss/a6b118576dce4c83989fe65d704cd799.jpg");
        if (apiResponse.getCode() != 0) {
            return ApiAjaxResult.error(apiResponse.getCode(),apiResponse.getData());
        }
        return ApiAjaxResult.success(apiResponse.getData());
    }

    @ApiOperation("查询账号")
    @GetMapping("/accountCheck")
    public String accountCheck() {
        String result = liveApiService.accountCheck("568");
        return result;
    }

    @ApiOperation("测试")
    @GetMapping("/queryOnlineStatus")
    public String queryOnlineStatus() {
        String result = liveApiService.queryOnlineStatus();
        return result;
    }

}
